home *** CD-ROM | disk | FTP | other *** search
- locate it
- 3FA7:032B 2E CS:
- 3FA7:032C A36505 MOV [psp_seg],AX ; save it
- 3FA7:032F 051000 ADD AX,0010 ; skip psp space
- 3FA7:0332 2E CS:
- 3FA7:0333 A38405 MOV [str_seg],AX ; save it as load address
- 3FA7:0336 83EB10 SUB BX,+10 ; subtract 10 from mem avail
- 3FA7:0339 2E CS:
- 3FA7:033A 8B0E8705 MOV CX,[ovrwrt]
- 3FA7:033E 3BC1 CMP AX,CX ; we writing over ourself ?
- 3FA7:0340 7708 JA 034A ; yes
- 3FA7:0342 2BC8 SUB CX,AX ; not yet
- 3FA7:0344 3BCB CMP CX,BX ; how bout (load size check)
- 3FA7:0346 7702 JA 034A ; yes
- 3FA7:0348 8BD9 MOV BX,CX ; are we loading in less than
- 3FA7:034A 81FB0010 CMP BX,1000 ; 64k ?
- 3FA7:034E 7308 JNB 0358 ; yes
- 3FA7:0350 8BC3 MOV AX,BX
- 3FA7:0352 B104 MOV CL,04
- 3FA7:0354 D3E0 SHL AX,CL ; convert to bytes
- 3FA7:0356 EB03 JMP 035B
- 3FA7:0358 B8FFFF MOV AX,FFFF ; else read in max bytes
- 3FA7:035B 50 PUSH AX
- 3FA7:035C 2E CS:
- 3FA7:035D 8B1E5305 MOV BX,[channel]
- 3FA7:0361 33C9 XOR CX,CX ; read in 64k
- 3FA7:0363 8BD1 MOV DX,CX
- 3FA7:0365 B80042 MOV AX,4200 ; this is a .COM program, so
- 3FA7:0368 CD21 INT 21 ; pt to start of file
- 3FA7:036A 2E CS:
- 3FA7:036B 8B1E5305 MOV BX,[channel]
- 3FA7:036F 59 POP CX ; get size
- 3FA7:0370 2E CS:
- 3FA7:0371 8E1E8405 MOV DS,[str_seg]
- 3FA7:0375 33D2 XOR DX,DX ; pt to load segment
- 3FA7:0377 51 PUSH CX
- 3FA7:0378 E86601 CALL 04E1
- 3FA7:037B B43F MOV AH,3F
- 3FA7:037D CD21 INT 21 ; read in program
- 3FA7:037F E86801 CALL 04EA
- 3FA7:0382 5E POP SI ; get size again
- 3FA7:0383 3BC6 CMP AX,SI ; get as many as requested
- 3FA7:0385 7503 JNZ 038A
- 3FA7:0387 E9E0FD JMP 016A ; not enough mem ?
- 3FA7:038A 2E CS:
- 3FA7:038B F606520502 TEST BYTE PTR [exe_fnc],02
- 3FA7:0390 7522 JNZ 03B4 ; ignore this if overlay
- 3FA7:0392 2E CS:
- 3FA7:0393 A18405 MOV AX,[str_seg] ; take load address
- 3FA7:0396 2D1000 SUB AX,0010
- 3FA7:0399 2E CS:
- 3FA7:039A A35B05 MOV [strt_seg],AX ; and point to its PSP
- 3FA7:039D 2E CS: ; set .COM IP
- 3FA7:039E C70659050001 MOV WORD PTR [strt_off],0100
- 3FA7:03A4 4E DEC SI ; put the stack at the end
- 3FA7:03A5 2E CS: ; probably FFFFh
- 3FA7:03A6 89365D05 MOV [nstk_sp],SI ; and save it for later
- 3FA7:03AA 2E CS:
- 3FA7:03AB A35F05 MOV [new_stk],AX ; stack is offset from PSP
- 3FA7:03AE 8ED8 MOV DS,AX ; push a return to PSP:0
- 3FA7:03B0 C7040000 MOV WORD PTR [SI],0000 ; on the stack
- 3FA7:03B4 2E CS:
- 3FA7:03B5 8B1E5305 MOV BX,[channel]
- 3FA7:03B9 E82501 CALL 04E1
- 3FA7:03BC B43E MOV AH,3E
- 3FA7:03BE CD21 INT 21 ; close the file !
- 3FA7:03C0 E82701 CALL 04EA
- 3FA7:03C3 2E CS:
- 3FA7:03C4 F606520502 TEST BYTE PTR [exe_fnc],02
- 3FA7:03C9 7403 JZ 03CE ; continue if program
- 3FA7:03CB E95901 JMP 0527 ; exit if overlay ( done! )
- 3FA7:03CE 2E CS:
- 3FA7:03CF 8B166505 MOV DX,[psp_seg] ; pt to the PSP
- 3FA7:03D3 BE0100 MOV SI,0001 ; pt to ?
- 3FA7:03D6 2E CS:
- 3FA7:03D7 A16105 MOV AX,[new_env]
- 3FA7:03DA 0BC0 OR AX,AX
- 3FA7:03DC 7405 JZ 03E3 ; prog has no environment
- 3FA7:03DE 48 DEC AX ; pt to memory control
- 3FA7:03DF 8ED8 MOV DS,AX ; block of the environment
- 3FA7:03E1 8914 MOV [SI],DX ; to indicate in use and
- 3FA7:03E3 2E CS: ; belongs to new program
- 3FA7:03E4 A16505 MOV AX,[psp_seg] ; pt to program's memory
- 3FA7:03E7 48 DEC AX ; control block and show
- 3FA7:03E8 8ED8 MOV DS,AX ; the program owns its
- 3FA7:03EA 8914 MOV [SI],DX ; memory
- 3FA7:03EC 52 PUSH DX ; 55 IS UNDOCUMENTED !!!
- 3FA7:03ED B455 MOV AH,55 ; SET UP PSP AT DX
- 3FA7:03EF CD21 INT 21 ; which changes DX to pt
- 3FA7:03F1 8EC2 MOV ES,DX ; to something of the command
- 3FA7:03F3 2E CS: ; shells.
- 3FA7:03F4 89168905 MOV [cll_psp],DX ; save ptr
- 3FA7:03F8 5A POP DX ; restore DX
- 3FA7:03F9 2E CS:
- 3FA7:03FA FF366105 PUSH [new_env] ; push the new env ptr
- 3FA7:03FE 26 ES:
- 3FA7:03FF 8F062C00 POP [002C] ; pop it into new PSP
- 3FA7:0403 2E CS:
- 3FA7:0404 8B366305 MOV SI,[new_siz]
- 3FA7:0408 03F2 ADD SI,DX
- 3FA7:040A 26 ES:
- 3FA7:040B 89360200 MOV [0002],SI ; pt to the top of memory
- 3FA7:040F 2E CS:
- 3FA7:0410 C5364E05 LDS SI,[prm_off] ; pt to the parm block
- 3FA7:0414 1E PUSH DS
- 3FA7:0415 56 PUSH SI
- 3FA7:0416 C57406 LDS SI,[SI+06] ; pt to first FCB
- 3FA7:0419 B90C00 MOV CX,000C ; to be copied into the PSP
- 3FA7:041C 51 PUSH CX
- 3FA7:041D BF5C00 MOV DI,005C
- 3FA7:0420 8A1C MOV BL,[SI] ; get first character
- 3FA7:0422 F3 REPZ
- 3FA7:0423 A4 MOVSB ; move it
- 3FA7:0424 33C0 XOR AX,AX
- 3FA7:0426 AB STOSW
- 3FA7:0427 AB STOSW ; make it unopened
- 3FA7:0428 59 POP CX
- 3FA7:0429 5E POP SI
- 3FA7:042A 1F POP DS
- 3FA7:042B 1E PUSH DS
- 3FA7:042C 56 PUSH SI
- 3FA7:042D C5740A LDS SI,[SI+0A] ; pt to second FCB
- 3FA7:0430 BF6C00 MOV DI,006C ; to be copied into the PSP
- 3FA7:0433 8A3C MOV BH,[SI] ; get first char again
- 3FA7:0435 F3 REPZ
- 3FA7:0436 A4 MOVSB ; move it
- 3FA7:0437 AB STOSW
- 3FA7:0438 AB STOSW ; make it unopened
- 3FA7:0439 5E POP SI
- 3FA7:043A 1F POP DS
- 3FA7:043B C57402 LDS SI,[SI+02] ; pt to the command line
- 3FA7:043E B98000 MOV CX,0080 ; MAX of 128 chars copied
- 3FA7:0441 8BF9 MOV DI,CX ; into the DTA at PSP + 80h
- 3FA7:0443 F3 REPZ
- 3FA7:0444 A4 MOVSB ; copy it
- 3FA7:0445 FEC9 DEC CL ; CL = FFh
- 3FA7:0447 2E CS:
- 3FA7:0448 3A3E8B05 CMP BH,[cur_dsk]
- 3FA7:044C 7604 JBE 0452 ; 2nd FCB is on same drive
- 3FA7:044E 8AF9 MOV BH,CL ; mark invalid FCB
- 3FA7:0450 EB02 JMP 0454 ; at PSP + 6Ch
- 3FA7:0452 32FF XOR BH,BH ; mark valid FCB
- 3FA7:0454 2E CS:
- 3FA7:0455 3A1E8B05 CMP BL,[cur_dsk] ; same for FCB at PSP + 5Ch
- 3FA7:0459 7604 JBE 045F
- 3FA7:045B 8AD9 MOV BL,CL ; mark FCB invalid
- 3FA7:045D EB02 JMP 0461
- 3FA7:045F 32DB XOR BL,BL ; mark FCB valid
- 3FA7:0461 E8D400 CALL 0538 ; set DS to pt to stk args
- 3FA7:0464 FF7414 PUSH [SI+14] ; Take the return address of
- 3FA7:0467 FF7412 PUSH [SI+12] ; the interrupt to be the
- 3FA7:046A FF7414 PUSH [SI+14] ; terminate address & the
- 3FA7:046D FF7412 PUSH [SI+12] ; CTRL-C return address ...
- 3FA7:0470 26 ES:
- 3FA7:0471 8F060A00 POP [000A] ; set the terminate address
- 3FA7:0475 26 ES:
- 3FA7:0476 8F060C00 POP [000C] ; up at PSP + 0Ah
- 3FA7:047A 33C0 XOR AX,AX
- 3FA7:047C 8ED8 MOV DS,AX
- 3FA7:047E 8F068800 POP [0088]
- 3FA7:0482 8F068A00 POP [008A] ; put it in int 22H, too
- 3FA7:0486 52 PUSH DX
- 3FA7:0487 1E PUSH DS
- 3FA7:0488 2E CS:
- 3FA7:0489 8E1E8905 MOV DS,[cll_psp]
- 3FA7:048D BA8000 MOV DX,0080
- 3FA7:0490 B41A MOV AH,1A
- 3FA7:0492 CD21 INT 21 ; set the DTA to PSP + 80h
- 3FA7:0494 1F POP DS
- 3FA7:0495 5A POP DX
- 3FA7:0496 2E CS:
- 3FA7:0497 F606520501 TEST BYTE PTR [exe_fnc],01
- 3FA7:049C 7426 JZ 04C4 ; avoid if a program
- 3FA7:049E 2E CS:
- 3FA7:049F C5365D05 LDS SI,[nstk_sp] ; pt to the new stack
- 3FA7:04A3 2E CS:
- 3FA7:04A4 C43E4E05 LES DI,[prm_off]
- 3FA7:04A8 26 ES:
- 3FA7:04A9 8C5D10 MOV [DI+10],DS ; return stack segment in
- 3FA7:04AC 4E DEC SI ; parm block
- 3FA7:04AD 4E DEC SI
- 3FA7:04AE 891C MOV [SI],BX ; push fcb status on it
- 3FA7:04B0 26 ES:
- 3FA7:04B1 89750E MOV [DI+0E],SI ; save new stack pointer
- 3FA7:04B4 2E CS:
- 3FA7:04B5 C5065905 LDS AX,[strt_off] ; and then save new starting
- 3FA7:04B9 26 ES:
- 3FA7:04BA 8C5D14 MOV [DI+14],DS ; segment and offset for the
- 3FA7:04BD 26 ES:
- 3FA7:04BE 894512 MOV [DI+12],AX ; debugger, this is the
- 3FA7:04C1 EB64 JMP 0527 ; UNDOCUMENTED function
- 3FA7:04C3 90 NOP ; call 01 used to load and
- 3FA7:04C4 E87800 CALL 053F ; not execute a program !!!
- 3FA7:04C7 2E CS:
- 3FA7:04C8 C5365905 LDS SI,[strt_off]
- 3FA7:04CC FA CLI ; stop interrupts
- 3FA7:04CD 2E CS:
- 3FA7:04CE 8E165F05 MOV SS,[new_stk] ; while we set up the
- 3FA7:04D2 2E CS:
- 3FA7:04D3 8B265D05 MOV SP,[nstk_sp] ; new stack
- 3FA7:04D7 FB STI ; start interrupts
- 3FA7:04D8 1E PUSH DS ; push start seg
- 3FA7:04D9 56 PUSH SI ; push start offset
- 3FA7:04DA 8EC2 MOV ES,DX ; pt to psp
- 3FA7:04DC 8EDA MOV DS,DX ; pt to psp
- 3FA7:04DE 8BC3 MOV AX,BX ; set PSP FCB flag
- 3FA7:04E0 CB RETF ; start new process !!!
- ;--------------------------------------------------------------------------
- ; a proc called several times in case theres an error during a DOS function
- ; call and control isn't returned to this program, this effectively frees
- ; up the memory allocated for an environment and I think the program to.
- 3FA7:04E1 53 PUSH BX
- 3FA7:04E2 BB0000 MOV BX,0000 ; indicate an available area
- 3FA7:04E5 E80D00 CALL 04F5 ; set the mem ctrl blks
- 3FA7:04E8 5B POP BX
- 3FA7:04E9 C3 RET
- ;--------------------------------------------------------------------------
- ; a proc which is called after a DOS function call which pts the environment
- ; back at the new process.
- 3FA7:04EA 53 PUSH BX
- 3FA7:04EB 2E CS:
- 3FA7:04EC 8B1E8905 MOV BX,[cll_psp] ; indicate area belongs
- 3FA7:04F0 E80200 CALL 04F5 ; to the new program
- 3FA7:04F3 5B POP BX
- 3FA7:04F4 C3 RET
- ;--------------------------------------------------------------------------
- ; this is the proc which does the actual setting of the memory control blocks
- ; on both the new program and the new environment
- 3FA7:04F5 1E PUSH DS
- 3FA7:04F6 50 PUSH AX ; save registers
- 3FA7:04F7 2E CS:
- 3FA7:04F8 A16105 MOV AX,[new_env]
- 3FA7:04FB 0BC0 OR AX,AX
- 3FA7:04FD 7407 JZ 0506 ; there is no env
- 3FA7:04FF 48 DEC AX ; pt to env's mem ctl blk
- 3FA7:0500 8ED8 MOV DS,AX
- 3FA7:0502 891E0100 MOV [0001],BX ; set to passed in value
- 3FA7:0506 2E CS:
- 3FA7:0507 A16505 MOV AX,[psp_seg] ; get new psp_seg
- 3FA7:050A 0BC0 OR AX,AX
- 3FA7:050C 7407 JZ 0515 ; we don't have one yet
- 3FA7:050E 48 DEC AX
- 3FA7:050F 8ED8 MOV DS,AX ; pt to PSP's mem ctl blk
- 3FA7:0511 891E0100 MOV [0001],BX ; set to passed in value
- 3FA7:0515 58 POP AX
- 3FA7:0516 1F POP DS ; restore registers
- 3FA7:0517 C3 RET
- ;--------------------------------------------------------------------------
- 3FA7:0518 E81D00 CALL 0538 ; set to origional stack
- 3FA7:051B FF7416 PUSH [SI+16] ; get something passed in
- 3FA7:051E 32E4 XOR AH,AH ;
- 3FA7:0520 8904 MOV [SI],AX ; zero top of the stack ?
- 3FA7:0522 9D POPF
- 3FA7:0523 F9 STC ; signal function error
- 3FA7:0524 EB09 JMP 052F ; on our way out
- 3FA7:0526 90 NOP
- 3FA7:0527 E80E00 CALL 0538 ; get origional stack
- 3FA7:052A FF7416 PUSH [SI+16] ; get flags
- 3FA7:052D 9D POPF ; for overlays ???
- 3FA7:052E F8 CLC ; everything went okay
- 3FA7:052F 9C PUSHF
- 3FA7:0530 E80C00 CALL 053F ; reset ctrl - c
- 3FA7:0533 8F4416 POP [SI+16] ; reset flags
- 3FA7:0536 EBA8 JMP 04E0 ; return
- ;--------------------------------------------------------------------------
- ; this proc pts the ds to the origional stack which called this from below
- 3FA7:0538 16 PUSH SS
- 3FA7:0539 1F POP DS
- 3FA7:053A C536B30B LDS SI,[0BB3] ; pt to stack args with ds
- 3FA7:053E C3 RET
- ;--------------------------------------------------------------------------
- ; this proc resets the Control - C flag to what it was before execution
- 3FA7:053F 50 PUSH AX
- 3FA7:0540 52 PUSH DX ; save regs
- 3FA7:0541 2E CS:
- 3FA7:0542 8A168605 MOV DL,[Ctl_CFLG] ; get old status
- 3FA7:0546 B80133 MOV AX,3301
- 3FA7:0549 CD21 INT 21 ; set it to what it was
- 3FA7:054B 5A POP DX
- 3FA7:054C 58 POP AX ; restore regs
- 3FA7:054D C3 RET